package me.ywd.poker.generator;

import me.ywd.poker.Common;
import me.ywd.poker.entity.Hand;
import me.ywd.poker.entity.Poker;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by AOC3 on 2017/2/23.
 */
public class HandsGenerator {
    public List<Poker> generateAllPokers() {
        List<Poker> pokers = new ArrayList<Poker>();
        for (String number : Common.NUMBERS) {
            for (String color : Common.COLORS) {
                Poker poker = new Poker();
                poker.setNumber(number);
                poker.setColor(color);
                pokers.add(poker);
            }
        }
        return pokers;
    }

    public List<Hand> generateAllHands() {
        List<Hand> hands = new ArrayList<Hand>();
        List<Hand> noDuplicatedHands = new ArrayList<Hand>();
        List<Poker> pokers = this.generateAllPokers();
        for (Poker poker : pokers) {
            for (Poker poker1 : pokers) {
                Hand hand = new Hand();
                if (!poker.equals(poker1)) {
                    Poker[] pokerTwo = {poker, poker1};
                    hand.setPokers(pokerTwo);
                    hands.add(hand);
                }
            }
        }
        for (Hand hand : hands) {
            if (!noDuplicatedHands.contains(hand)) {
                noDuplicatedHands.add(hand);
            }
        }
        return noDuplicatedHands;
    }
}
